<?php
	require "../dao/grade_dao.php";
	require "../dao/class_dao.php";
	require "../dao/college_dao.php";
	require "../dao/staff_dao.php";
	$grades = selectAllgrades();
	$classes = selectAllclasses();
	$colleges = selectAllcolleges();
	
	$stuid = $_REQUEST["stuid"];
	$student = selectByStuid($stuid);
?>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>学生学籍信息输入</title>
	<link rel="stylesheet" type="text/css" href="../css/register.css"/>
	<script src='../js/jquery-1.2.6.min.js'></script>
	<style>
		#thumbnail{
			position: absolute;
			width:120px;
			height:170px;
			border:1px solid #000;
			right:10px;
			cursor: pointer;
		}
		input[type="file"]{
			display: none;
		}
		input[type="text"]{
			width:160px;
		}
		input[type='date']{
			width:240px;
		}
		#sidnumber{
			width:320px;
		}
		#snative{
			width:790px;
		}
		#sdesc{
			width:890px;
			height:200px;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$('#simage').change(function(){
				var target = this.files[0];
				if(/\.png|\.jpg|\.jpeg|\.bmp|\.gif$/i.test(target.name)){
					$('#thumbnail').attr('src',window.URL.createObjectURL(target));
				}else{
					alert("图片格式错误");
				}
			})
		})
	</script>
</head>
<body>
	<div id="wrap">
		<form action="Stu_roll_update_server.php" method="post" autocomplete="off" enctype="multipart/form-data">
			<input type="hidden" name="stuid" value="<?=$student['stuid']?>" />
			
			<input type="file" name="simage" id="simage" accept=".png, .jpg, .jpeg, .gif, .bmp">
			<label for="simage">
				<img src="loadimage.php?stuid=<?=$student['stuid']?>" id='thumbnail'>
			</label>
			
			<label for="sname"><span>姓名</span></label>
			<input type="text" name="sname" id="sname" value="<?=$student['sname']?>"/>
			<label for="snumber"><span>学号</span></label>
			<input type="text" name="snumber" id="snumber" value="<?=$student['snumber']?>"/>
			<span>性别</span>
			<input type="radio" name="ssex" value="male" <?=$student['ssex']=='male'?'checked':''?> />男
			<input type="radio" name="ssex" value="female" <?=$student['ssex']=='female'?'checked':''?> />女
			
			<br />
			
			<select name="scollegeid">
				<option value="0">--请选择学院--</option>
				<?php
					foreach($colleges as $college){
						echo "<option value='{$college["collegeid"]}'" . ($student['scollegeid']==$college['collegeid']?'selected':'') . ">{$college["collegename"]}</option>";
					}	
				?>
			</select>
			<select name="sgradeid">
				<option value="0">--请选择年级--</option>
				<?php
					foreach($grades as $grade){
						echo "<option value='{$grade["gradeid"]}'" . ($student['sgradeid']==$grade['gradeid']?'selected':'') . ">{$grade["gradename"]}</option>";
					}	
				?>
			</select>
			<select name="sclassid">
				<option value="0">--请选择班级--</option>
				<?php
					foreach($classes as $class){
						echo "<option value='{$class["classid"]}'" . ($student['sclassid']==$class['classid']?'selected':'') . ">{$class["classname"]}</option>";
					}	
				?>
			</select>
			<label for="ssys"><span>年制</span></label>
			<input type="text" name="ssys" id="ssys" value="<?=$student['ssys']?>" readonly />
			
			<br />
			
			<label for="senter"><span>入学时间</span></label>
			<input type="date" name="senter" id="senter" value="<?=$student['senter']?>" />
			<label for="sgrad"><span>毕业时间</span></label>
			<input type="date" name="sgrad" id="sgrad" value="<?=$student['sgrad']?>" />
			
			<br />
			
			<label for="sbirth"><span>出生日期</span></label>
			<input type="text" name="sbirth" id="sbirth" value="<?=$student['sbirth']?>" />
			<label for="sidnumber"><span>证件号码</span></label>
			<input type="text" name="sidnumber" id="sidnumber" value="<?=$student['sidnumber']?>" />
			
			<br />
			
			<label for="snative"><span>籍贯</span></label>
			<input type="text" name="snative" id="snative" value="<?=$student['snative']?>" />
			
			<br />
			
			<label for="sdesc"><span>简介</span></label><br />
			<textarea name="sdesc" id="sdesc"><?=$student['sdesc']?></textarea>
			
			
			<input type="reset" value="重   置" />
			<input type="submit" value="修   改" />
		</form>
	</div>
</body>
</html>